package br.com.minhabiblia.servlet;

import java.io.IOException;
import java.util.logging.Logger;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import br.com.minhabiblia.util.MinhaBibliaOnLineCacheImportador;

@SuppressWarnings("serial")
public class MinhaBibliaOnLineImportadorControlador extends HttpServlet {
	
	private static final MinhaBibliaOnLineCacheImportador loaderCache = MinhaBibliaOnLineCacheImportador.getInstance();

	private static final Logger log = Logger.getLogger(MinhaBibliaOnLineImportadorControlador.class.getName());
	
	@Override
	public void init() throws ServletException {
		log.info("Iniciando " + MinhaBibliaOnLineImportadorControlador.class.getCanonicalName());
		loaderCache.carregarBiblia();
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		process(req, resp);
	}
	
	@Override
	public void doGet(HttpServletRequest req, HttpServletResponse resp) throws IOException {
		process(req, resp);
	}
	
	private void process(HttpServletRequest req, HttpServletResponse resp) {
		loaderCache.carregarBiblia();
	}

}
